"use strict";

!function () {
  var t = localStorage.getItem("city_name") || "请手动选择";$(".city .choose-city").html(t), $(".area .change-city").mouseover(function () {
    $(".area .box").show();
  }), $(".area").mouseleave(function () {
    $(".area .box").hide();
  }), $(".tab li").click(function () {
    var t = $(this).index();$(this).siblings().removeClass("cur"), $(this).addClass("cur"), $(".tab-content").hide(), $(".tab-content").eq(t).show();
  }), $(".tab-content").on("click", "a", function () {
    var t = $(this).text(),
        a = $(this).parents(".tab-content").index();$(".tab-content").eq(a - 1).find(".city").removeClass("cur"), $(this).parents(".city").addClass("cur"), $(".tab li").eq(a - 1).text(t), 3 != a && ($(".tab li").removeClass("cur"), $(".tab li").eq(a).addClass("cur"), $(".tab li").eq(a).show(), $(".tab-content").eq(a - 1).hide(), $(".tab-content").eq(a).show());
  }), $(".tab-content").on("click", "span", function () {
    $(this).prev().text(), $(this).parents(".city").attr("area-id");$(".area .box").hide();
  }), $(".tab-content").on("click", "span", function () {
    var t = $(this).prev().text(),
        a = $(this).parents(".city").attr("area-id");localStorage.setItem("city_name", t), localStorage.setItem("city_id", a), location.reload();
  }), $.get("http://kg.zhaodashen.cn/mt/web/area/index.jsp", { type: "一级", pid: 1 }, function (t) {
    if (200 === t.meta.state) {
      var e = "";$.each(t.data, function (t, a) {
        e += "\n              <div class=\"city\" area-id=\"" + a.area_id + "\"><a href=\"javascript:;\">" + a.area_name + "</a><span>-</span></div>\n              ";
      }), $(".tab-content:eq(0)").html(e);
    }
  }, "json"), $(".box").on("click", "a", function () {
    var a = $(this).parents(".tab-content").index();var t, e;[1, 2].includes(a) && (t = ["二级", "三级"][a - 1], e = $(this).parents(".city").attr("area-id"), $.get("http://kg.zhaodashen.cn/mt/web/area/index.jsp", { type: t, pid: e }, function (t) {
      console.log(t);var e = "";$.each(t.data, function (t, a) {
        e += "\n                <div class=\"city\" area-id=\"" + a.area_id + "\"><a href=\"javascript:;\">" + a.area_name + "</a><span>-</span></div>\n                ";
      }), $(".tab-content:eq(" + a + ")").html(e);
    }, "json"));
  });
}();